<?php 
define('_VIEW_MODEL_','admin');
session_start();
$statu = $_SESSION['statu'];
require_once("../init.php");
if(!$statu){
	echo "<script>window.parent.location.href='./index.php'</script>";
}
if(isset($act)&&$act=="add"){
	$imageurl = '';
	$nowtime  = @time();
	$usingtime= intval($usingday)*24*3600 + intval($usinghour)*3600 + intval($usingminter)*60;
	$func = '';
	if (!empty($_FILES["imageurl"]["name"])){
	//图片上传 start
		$path=ROOT."/image/upload/"; //上传路径 
		if(!file_exists($path)) 
		{ 
			//检查是否有该文件夹，如果没有就创建，并给予最高权限 
			@mkdir("$path", 0700); 
		}//END IF 
		//允许上传的文件格式 
		$tp = array("image/gif","image/pjpeg","image/png"); 
		//检查上传文件是否在允许上传的类型 
		if(!in_array($_FILES["imageurl"]["type"],$tp)) 
		{ 
			echo "格式不对"; 
			exit; 
		}//END IF 
		if($_FILES["imageurl"]["name"]) 
		{ 
			$file1=$_FILES["imageurl"]["name"]; 
			$file2 = $path.time().$file1; 
			$flag=1; 
		}//END IF 
		if($flag) $result=move_uploaded_file($_FILES["imageurl"]["tmp_name"],$file2); 
		//特别注意这里传递给move_uploaded_file的第一个参数为上传到服务器上的临时文件 
		if($result) 
		{ 
			$imageurl =  $file2;
		}//END IF 
		//图片上传 end
	}
	if ($linksta == 'user'){//会员表 勋章添加
		$endtime  = $nowtime + $usingtime;
		$func   = "update $telper"."$linksta set `medalid` = $imageurl, `usingtime` = $endtime ";
		$func  .= 'where id = $id;';
	}
	if ($linksta == 'novel'){//小说评价  鲜花 板砖
		$func   = "update $telper"."$linksta set `$praise` = `$praise` + 1 ";
		$func  .= 'where id = $id;';
	}
	if ($linksta == 'bbs_book'){//书会置顶
		$func   = "update $telper"."$linksta set `upbook` = 1 ";
		$func  .= 'where id = $id;';
	}
	if ($linksta == 'bbs_book'){//小说置顶
		$endtime  = $nowtime + $usingtime;
		$func   = "update $telper"."$linksta set `upbook` = 1, `uptime` = $endtime";
		$func  .= 'where id = $id;';
	}
	$db->Execute("insert into {$telper}prop set `title` = '$linkname',`summary` = '$briefintro',`money` = '$price',`func` = '$func',`rank` = '$proprank',`created` = '$nowtime',`state` = '0'");
	header("Location:proplist.php"); 
	exit;
}
$act = "add";

$smartyObj->assign('title',$admintitle);
$smartyObj->assign('moneyname',$moneyname);
$smartyObj->assign('adminpropadd',$adminpropadd);
$smartyObj->assign('act',$act);
$smartyObj->assign('propstyle',$propstyle);
$smartyObj->display("propadd.tpl");
?>